<!DOCTYPE html>
<html lang="cn" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{_fragments::common_header(~{::title})}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../static/css/bootstrap.min.css"
	th:href="@{/static/css/bootstrap.min.css}" rel="stylesheet">
<script src="../../static/js/jquery-3.2.1.js"
	th:src="@{/static/js/jquery-3.2.1.js}"></script>
<script src="../../static/js/bootstrap.min.js"
	th:src="@{/static/js/bootstrap.min.js}"></script>
<title>逍遥论坛 ›修改用户信息</title>
</head>
<body>
	<!-- 引入header文件 -->
	<header th:replace=" _fragments:: header"></header>

	<div style="width: 70%; margin: 1% 2% 1% 5%; float: left;">
		<div class="panel panel-default" id="main" style="">
			<div class="panel-heading" style="background-color: white">
				<a href="<%=basePath%>">逍遥论坛</a> › 修改用户信息 ›
				<a href="<%=basePath%>" th:if="${userInfo.userNick==null||userInfo.userNick==''}" th:text="${userInfo.userName}"></a> 
            <a href="<%=basePath%>" th:if="${userInfo.userNick!=null||userInfo.userNick!=''}" th:text="${userInfo.userNick}"></a> 
			</div>

			<div class="panel-body">

				<form action="updateUserInfo.do" id="myUpdateForm" method="POST"
					class="form-horizontal" role="form">
					<div class="form-group">
						<label class="col-sm-2 control-label">ID</label>
						<div class="col-sm-5">
							<p class="form-control-static" th:text="${userInfo.userId}">${userObject.user_id}</p>
						</div>
							 <div class="col-sm-5">
                        <input type="text"  name="userId" th:value="${userInfo.userId}" readonly />
                        <!-- readonly="readonly" -->
                        <!-- readonly 属性规定输入字段为只读可复制，但是，用户可以使用Tab键切换到该字段，可选择,可以接收焦点，还可以选中或拷贝其文本。后台会接收到传值. readonly 属性可以防止用户对值进行修改。 -->
                    </div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">用户名</label>
						<div class="col-sm-5">
							<p class="form-control-static" th:text="${userInfo.userName}">${userObject.user_name}</p>
						</div>
                    <div class="col-sm-5">
                        <input type="text"  name="user_name" th:value="${userInfo.userName}" readonly />
                    </div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">昵称</label>
						<div class="col-sm-5">
							<p class="form-control-static" th:text="${userInfo.userNick}">${userObject.user_nick}</p>
						</div>
						<div class="col-sm-5">
							新昵称：<br>
								<input type="text" name="userNick"
								th:value="${userInfo.userNick}" required />
						</div>
					</div>
								<div class="form-group">
						<label class="col-sm-2 control-label">密码</label>
						<div class="col-sm-5">
							<p class="form-control-static"></p>
						</div>
						<div class="col-sm-5">
							如需修改请输入新密码：<br> <input type="password" id="userPassword" name="userPassword"
								 required />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">用户状态</label>
						<div class="col-sm-5">
							<p class="form-control-static" th:switch="${userInfo.userStatus}">
								<span th:case="1">禁用</span> <span th:case="2">锁定</span> <span
									th:case="*">正常</span>
								<!--  <c:choose>
                                <c:when test="${userObject.user_status == 1}">禁用</c:when>
                                <c:when test="${userObject.user_status == 2}">锁定</c:when>
                                <c:otherwise>正常</c:otherwise>
                            </c:choose> -->
							</p>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">用户权限</label>
						<div class="col-sm-5">
							<p class="form-control-static" th:switch="${userInfo.userType}">
								<span th:case="0">超级管理员</span> 
								<span th:case="1">管理员</span> 
								<span th:case="2">普通用户</span>
							</p>
						</div>
					</div>

					<input class="btn btn-warning" id="xiugai" type="button" value="修改"
						onclick="update_confirm()"> <input class="btn btn-default"
						type="reset" value="重填"> <input type="button"
						class="btn btn-default" value="返回" style="margin-left: 10%"
						onclick="window.location.href='<%=basePath%>getUserInfo.do?userId=${userObject.user_id}'" />
				</form>
			</div>
		</div>
	</div>

	<!-- 引入侧边栏文件 -->
	<!-- <%@ include file="side.jsp"%> -->
	<nav th:replace="side:: nav"></nav>

	<!-- 引入footer文件 -->
	<!-- <%@ include file="footer.jsp"%> -->
	<footer th:replace="_fragments:: footer"></footer>

	<script>
		function update_confirm() {
			var r = confirm("确定修改?")
			if (r == true) {
				if($("#userPassword").val()!=''){
					var user_password= $("#userPassword").val();
					//获取固定盐
					var salt = "1a2b3c4d";
					//进行拼装
					var str = "" + salt.charAt(0) + salt.charAt(2) + user_password + salt.charAt(5) + salt.charAt(4);
					//加密
					//var  = md5(str);
					document.getElementById("userPassword").value = hex_md5(str);
				}else{
					document.getElementById("userPassword").value = '';
				}
				var form = document.getElementById("myUpdateForm"); // 由id获取表单
				form.submit();
			} else {
			}
		}
	</script>

</body>
</html>